package cn.shop.admin.controller;

import cn.shop.admin.entity.backPaymentChannelModule.WithdrawAlipayChannel;
import cn.shop.admin.service.WithdrawAlipayChannelService;
import cn.shop.utils.ApiResult;
import cn.shop.utils.Putif;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author : 李一涵
 * @date : Created in 2022-7-25 11:06
 * @description :
 */
@RestController
@RequestMapping("/api/v1/withdraw/channel")
public class WithdrawAlipayChannelController {

    @Resource
    private WithdrawAlipayChannelService channelService;

    @GetMapping("")
    public ApiResult<List<Map<String, Object>>> allChannel() {
        List<WithdrawAlipayChannel> channelList = channelService.list();
        return ApiResult.success(channelList.stream()
                .map(c -> Putif.start()
                        .anyway("value", c.getId())
                        .anyway("label", c.getName())
                        .get())
                .collect(Collectors.toList()));
    }

}
